<?php
namespace Bundle\ModuleBundle\DataSource;

class DataRow implements \IteratorAggregate
{
	private $_item;
	
	public $id;
	public $hidden;
	
	public function __get($name)
	{
		try
		{
			return call_user_func(array($this->_item, 'get' . ucfirst($name))); 
		}
		catch (\Exception $e)
		{
			die(\var_dump($e));
		}	
	}
	public function __set($name, $value)
	{
	    try
        {
            call_user_func(array($this->_item, 'set' . ucfirst($name)), $value); 
        }
        catch (\Exception $e)
        {
            die(\var_dump($e));
        }
	}
	
	public function __construct($item)
    {
    	$this->id = $item->getId();
    	$this->hidden = $item->getHidden();
        $this->_item = $item;
    }
    
    public function getIterator()
    {
        return new ArrayIterator($this->_item);
    }
    
    public function getItem()
    {
    	return $this->_item;
    }
}